<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8"/>
	<meta name="baidu-site-verification" content="JdMif0g2tL" />
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
	<title>angular</title>
</head>
<body ng-app="myApp">

<div ng-controller="appCtrl">
	<input type="text" ng-model="abc">
	<h1 repeat-num="3">
		<p ickt-bind="abc"></p>
	</h1>
</div>

<script type="text/javascript">
	document.getElementsByTagName('html')[0].style.fontSize=window.screen.width/10+'px';
</script>
<script src="../js/angular.min.js" charset="utf-8"></script>
<script type="text/javascript">
	var app =angular.module('myApp', []);
	
	app.controller('appCtrl', ['$scope', function($scope){
		$scope.abc='hellow';
	}]);
	app.directive('icktBind', function(){
		// Runs during compile
		return {
			restrict: 'A', // E = Element, A = Attribute, C = Class, M = Comment
			// scope: {
			// 	key:'=icktBind'
			// }, // {} = isolate, true = child, false/undefined = no change
			link: function(scope, jqlite, attrs) {
				//监听icktBind的变化
				scope.$watch(attrs.icktBind,function(newValue,oldValue,scope){
					jqlite.html(newValue);
				});
				//将key放在元素内容里
				
				//获取num值
				var num=attrs.repeatNum;
				console.log(num);
				console.log(jqlite.clone())
				for(var i=0;i<num;i++){
					jqlite.after(jqlite.clone())
				}
			}
		};
	});
	app.directive('repeatNum',function(){
		return{
			restrict:'A',
			link:function(scope, jqlite, attrs){
				var num=attrs.repeatNum;
				var dom=jqlite.children();
				for (var i = 0; i < num; i++) {
					jqlite.after(dom.clone())
				}
			}
		}
	})
</script>
</body>
</html>
<!--应该是13.8，时间-2017-05-07->